<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Jobs extends MY_Controller {
	function __construct(){
		parent::__construct();
		$this->load->model('page_model');
		$this->load->model('article_model');
		$this->load->model('gallery_model');
		$this->load->model('coltypes_model');
	}
	
	public function index($page=1){
		/*分页*/
		$config['base_url'] = SITE_URL.'jobs/index/';//分页地址
		$config['uri_segment'] = 3;//页码所在URI段
		//计算当前页面新闻总条数
		$where=array('cid'=>13,'audit'=>1);
		$config['total_rows'] = $this->db->where($where)->from('product')->count_all_results();
		$config['per_page'] = 6;//每页显示的条数
		$config['use_page_numbers'] = TRUE;//默认分页URL中是显示每页记录数,启用use_page_numbers后显示的是当前页码。
		$data['fenye']=$this->article_model->pro_page($config,$page,$where);
		$data['seo']=$this->db->get_where('columns',array('id'=>13))->row_array();//获取seo
		$this->load->view('jobs',$data);
	}
	
	public function job_ajax(){
		$page=$_GET['page'];
		header('Content-type:application/json');
		/*分页*/
		$config['base_url'] = SITE_URL.'job/index/';//分页地址
		$config['uri_segment'] = 3;//页码所在URI段
		//计算当前页面新闻总条数
		$where=array('cid'=>13,'audit'=>1);
		$config['total_rows'] = $this->db->where($where)->from('product')->count_all_results();
		$config['per_page'] = 6;//每页显示的条数
		//判断是否有下一页
		if($config['total_rows']>$page*$config['per_page']){
			$back['status']= 'yes';
		}else{
			$back['status']= 'no';
		}
		$config['use_page_numbers'] = TRUE ;//默认分页URL中是显示每页记录数,启用use_page_numbers后显示的是当前页码。
		$data['fenye']=$this->article_model->pro_page($config,$page,$where);
		$html= "";
		foreach ($data['fenye']['new_con'] as $k =>$v){
			$content=msubstr(str_replace('&nbsp;','',trim(strip_tags($v['content']))),0,80);
			$html.= '<div class="w1190 jobs-frame">
								<div class="jobs-title">'.$v['title'].'</div>
								<div class="jobs-simple">
									'.$content.'
									<div class="jobs-more"></div>
								</div>
								<div class="jobs-detail">
									<div class="jobs-d-title">
										<div class="fl d-title-f">工作地址：<span>'.$v['dz'].'</span></div>
										<div class="fl d-title-f">人数：<span>'.$v['mans'].'</span></div>
										<div class="fr d-title-f2">工作年限：<span>'.$v['years'].'</span></div>
									</div>
									<div class="jobs-text">
										'.$v['content'].'
									</div>
									<div class="jobs-less"></div>
									<div class="resume">投递简历</div>
								</div>
							</div>' ;
		}
		$back['list']=$html;
		exit(json_encode($back));
	}
	
	public function apply($id=''){
		$data['banner']=$this->page_model->get_page($cid=77);
		$data['ht']=$this->page_model->get_page($cid=58);
		if(!empty($_POST)){
			$_POST['timeline']=now();
			$data['userinfo'] = $this->db->insert('recruit_apply', $_POST);
			goto_message('提交成功','jobs/index');
		}
		$data['rs']=$this->db->get_where('product',array('id'=>$id))->row_array();
		$data['seo']=array('title'=>'在线应聘');
		$this->load->view('apply',$data);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}